
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title>后台首页</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/component/pear/css/pear.css">
    <%--<link rel="stylesheet" href="<%=request.getContextPath()%>/admin/css/other/login.css" />--%>

    <link rel="stylesheet" href="<%=request.getContextPath()%>/admin/css/loader.css"/>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/admin/css/admin.css"/>
    <!-- 主 题 更 换 -->
    <style id="pearadmin-bg-color"></style>
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
<!-- 布 局 框 架 -->
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <!-- 顶 部 左 侧 功 能 -->
        <ul class="layui-nav layui-layout-left">
            <li class="collaspe layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
            <li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a></li>
        </ul>
        <!-- 顶 部 右 侧 菜 单 -->
        <div id="control" class="layui-layout-control"></div>
        <ul class="layui-nav layui-layout-right">
            <%--<li class="layui-nav-item layui-hide-xs"><a href="#"
                                                        class="fullScreen layui-icon layui-icon-screen-full"></a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="http://www.pearadmin.com"
                                                        class="layui-icon layui-icon-website"></a></li>--%>
            <li class="layui-nav-item">
                <!-- 头 像 -->
                <a href="javascript:;">
                    <img src="<%=request.getContextPath()%>/admin/images/avatar.jpg" class="layui-nav-img">
                    <span >${userInfo.username}</span>
                </a>
                <!-- 功 能 菜 单 -->
                <dl class="layui-nav-child">
                    <dd><a href="javascript:void(0);" id="changePWD">修改密码</a></dd>
                    <dd><a href="javascript:void(0);" class="logout">注销登录</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
        </ul>
    </div>
    <!-- 侧 边 区 域 -->
    <div class="layui-side layui-bg-black">

        <!-- 顶 部 图 标 -->
        <div class="layui-logo">
            <img class="logo"></img>
            <span class="title"></span>
        </div>
        <!-- 侧 边 菜 单 -->
        <div class="layui-side-scroll">
            <div id="sideMenu"></div>
        </div>
    </div>
    <div class="layui-body">
        <div id="content"></div>
    </div>
</div>
<!-- 遮 盖 层 -->
<div class="pear-cover"></div>
<!-- 加 载 动 画-->
<div class="loader-main">
    <div class="loader"></div>
</div>

<!-- 通用JS -->
<div>
    <script src="<%=request.getContextPath()%>/component/layui/layui.js"></script>
    <script src="<%=request.getContextPath()%>/component/pear/pear.js"></script>
    <script src="<%=request.getContextPath()%>/component/jquery.min.js"></script>
    <script src="<%=request.getContextPath()%>/component/myCommon.js" charset="utf-8"></script>
</div>

<script th:inline="javascript">
    layui.use(['admin','jquery','popup'], function() {
        var $ = layui.jquery;
        var admin = layui.admin;
        var popup = layui.popup;
        admin.render();

        // 登出逻辑
        admin.logout(function(){
            popup.success("注销成功",function(){
                location.href = "<%=request.getContextPath()%>/system/logout";
            })
            // 注销逻辑 返回 true / false
            return true;
        })
        
        $("#changePWD").click(function () {
            layer.prompt({
                formType: 1,
                title: '请输入密码'
            }, function(value, index, elem){

                if(value.length < 6){
                    layer.alert('密码必须是大于6位', {icon: 2});
                    layer.close(index);
                    return;
                }

                $.ajax({
                    url: '<%=request.getContextPath()%>/system/user/changePWD',
                    dataType: 'json',
                    data:{pwd:value},
                    type: 'PUT',
                    success: function(result) {
                        if (result.code == 0) {
                            layer.msg(result.msg, {
                                icon: 1,
                                time: 1000
                            }, function() {
                            });
                        } else {
                            layer.msg(result.msg, {
                                icon: 2,
                                time: 1000
                            });
                        }
                    }
                })

                layer.close(index);
            });
        })

    })
</script>
</body>
</html>

